﻿using MebAppMarketplace.Model;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MebAppMarketplace.Biz
{
    public class AppEventService : BaseService<Model.AppEvent>
    {
        public AppEventService(DbContext db) : base(db) { }
        public void AddEvent(JsonModel.AppEventRequest appEvent)
        {
            var model = new AppEvent();
            model.ID = Guid.NewGuid();
            model.AppName = appEvent.Name;
            model.AppVersion = appEvent.AppVersion;
            model.Channel = appEvent.Channel;
            model.Content = appEvent.Content;
            model.DeviceBrand = appEvent.DeviceBrand;
            model.DeviceID = appEvent.DeviceID;
            model.DeviceModel = appEvent.DeviceModel;
            model.EventTime = appEvent.EventTime;
            model.Name = appEvent.Name;
            model.Os = appEvent.Os;
            model.PrevEvent = appEvent.PrevEvent;
            model.StackTrace = appEvent.StackTrace;
            model.UserID = appEvent.UserID;
            model.UserSID = appEvent.UserSID;
            DbSet.Add(model);
            Db.SaveChanges();
        }
    }
}
